<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="moduleList" />
<script type="text/javascript">
$(document).ready(function() {
	$("#btnQuery").click(function(){
		$("#salesForm").submit();
	});
	$(".o-a-form-date").datetimepicker({
		language : 'zh-CN',
		autoclose : true,
		minView : 2,
		todayBtn : 1,
		pickerPosition : "bottom-left"
	});
});


/**
 * @param href	URL
 * @param tabId  搜索范围
 * @param urlParam   要替换为具体ID的字符
 */
function Oosp_confirmChked(href,tabId,urlParam){
	var ids = new Array();
	$('#'+tabId).find("input[type='checkbox'][data-ckb-id]").each(function(){
		var $this = $(this);
		if($this.prop('checked')){
			ids.push($(this).attr("data-ckb-id"))  ;
		}
	});
	if(ids.length==0){
		$.jBox.tip("请先勾选确认对账的数据！","${error}",{persistent:true,opacity:0});
	}else{
		top.$.jBox.confirm('确认勾选这些数据吗？','系统提示',function(v,h,f){
			if(v=='ok'){	
				Oosp_Loading('正在提交，请稍等...');
				alert(urlParam);
				if(urlParam){
					alert(href);
					href = href.replace(urlParam,ids+'');
				}
				alert(href);
				funform(href,'_self');
			}
		},{buttonsFocus:1});
	}
}

/* function checkData(){
	if ($("#endDate").val().length !=0 && $("#startDate").val().length!=0) {
			if ($("#endDate").val() < $("#startDate").val()) {
				alert("结束日期小于开始日期,请重新选择日期！");
				return false;
			} else {
				return true;
			}
		}
      return  true;
	} */
</script>
</head>
<body>
	<form:form name="listForm"  modelAttribute="statementPospaySaleSupplier" method="post" class="form-inline" role="form">
	    <input type="hidden" name="deleteIds" >
		<ol class="breadcrumb map_1">
			<li><a href="${contextPath}/index">首页</a></li>
			<li><a href="${contextPath}/statement/stm/payinslip/list?navId=${navId}">采购销售</a></li>
			<li class="active">销售对账</li>
		</ol>
		<div class="o-l-search-builder f_1">
		   <div id="statement-search-builder" class="collapse" style="height:auto;">
	             <div class="f_2">
	                 <div class="form-group col-sm-6">
	                      <label for="inputEmail3" class="col-sm-3 control-label f_4">销售日期：</label>
	                      <div class="col-sm-9 f_6">
	                        <div class="input-group date o-a-form-date" data-date="" data-date-format="yyyy-mm-dd">
	                            <input class="form-control f_13" id="saleDate" name="saleDate" value="<fmt:formatDate value="${statementPospaySaleSupplier.saleDate}" pattern="yyyy-MM-dd"/>" type="text" />
	                            <span class="input-group-addon f_time"><i class="glyphicon glyphicon-remove"></i></span>
	                            <span class="input-group-addon f_time"><span class="glyphicon glyphicon-calendar"></span></span>
	                        </div>
	                      </div>
	                  </div>
	              <div class="f_2">
	                  <div class="form-group col-sm-6">
	                      <label for="orderStatus" class="col-sm-3 control-label f_7">对账类型:</label>
	                      <div class="col-sm-9 f_6">
	                          <ossp:select dictType="CHK_FLAG" class_="f_5" id="chkFlag"  name="chkFlag"></ossp:select>
	                      </div>
	                  </div>
	             </div>  
	           </div> 
	         </div>
	         <div class="f_8">
	              <div class="f_2">
	                  <div class="col-sm-8 f_6">
	                       <form:input id="shopName" path="shopName" class="f_5" placeholder="门店"/>
	                  </div>
	                  <button type="submit"   class="btn btn-warning btn_1">查&nbsp;询</button>
	                  <button  class="btn btn-warning btn_1" type="button" onclick="Oosp_confirmChked('${contextPath}/biz/statement/pospaySaleSupplier/ids/confirmChked?navId=${navId}','table1','ids')">确认对账</button>
	                  
	             </div>	
	         </div>
	         <div class="o-l-chevron-down"><a href="#" class="btn btn-default" data-toggle="collapse" data-target="#statement-search-builder" id="chevronDownBtn" role="button"><span id="glyphiconspan" class="glyphicon glyphicon-chevron-down"></span></a>
	         </div>
	     </div>
		<tags:message content="${message}"/>
		<div class="o-l-search-builder f_9">
			<table class="table table-striped table-hover o-l-table table-bordered" id="table1">
				<thead class="t_1">
					<tr>
					    <th style="width: 1px"><input type="checkbox" data-ckb="all"></th>
						<th>门店</th>
						<th>商品条码</th>
						<th>商品名称</th>
						<th>楼层</th>
						<th>销售金额</th>
						<th>是否对账</th>
						<th>销售日期</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${page.list}" var="pospaySaleSupplier">
						<tr data-herf="${contextPath}/biz/statement/pospaySaleSupplier/viewDetail?shopNo=${pospaySaleSupplier.shopNo}&barCode=${pospaySaleSupplier.barCode}&saleDate=<fmt:formatDate value="${pospaySaleSupplier.saleDate}" pattern="yyyy-MM-dd"/>" data-target="_self">
						    <c:if test="${pospaySaleSupplier.chkFlag=='02'||pospaySaleSupplier.chkFlag=='03'}"><td></td></c:if>
						     <c:if test="${pospaySaleSupplier.chkFlag=='01'}"><td class="o-l-tab-ckb" >
								<input type="checkbox" data-ckb-id="${pospaySaleSupplier.shopNo},<fmt:formatDate value="${pospaySaleSupplier.saleDate}" pattern="yyyy-MM-dd"/>,${pospaySaleSupplier.barCode}">
							</td></c:if>
							<td>${pospaySaleSupplier.shopName}</td>
							<td>${pospaySaleSupplier.barCode}</td>
							<td>${pospaySaleSupplier.goodsName}</td>
							<td>${pospaySaleSupplier.floorName}</td>
							<td>${pospaySaleSupplier.saleAmount}</td>
							<td><ossp:value dictType="CHK_FLAG" key="${pospaySaleSupplier.chkFlag}"></ossp:value></td>
                            <td><fmt:formatDate value="${pospaySaleSupplier.saleDate}" pattern="yyyy-MM-dd"/></td>						</tr>
					</c:forEach>
				</tbody>
			</table>
        </div>
		<pager:pager pageSize="${page.pageSize}" pageNo="${page.pageNo}" url="" total="${page.total}"/>
		<script type="text/javascript" src="${staticPath}/js/list.js"></script>
  </form:form>
</body>
</html>
